<?php
/**
 * Created by PhpStorm.
 * User: lili
 * Date: 19-1-20
 * Time: 下午10:18
 */


//进队的处理


$redis = new Redis();

$redis->connect('127.0.0.1',6379);

$dbms='mysql';     //数据库类型
$host='localhost'; //数据库主机名
$dbName='redis';    //使用的数据库
$user='root';      //数据库连接用户名
$pass='123456';          //对应的密码
$dsn="$dbms:host=$host;dbname=$dbName";

try {
    $dbh = new PDO($dsn, $user, $pass); //初始化一个PDO对象
    echo "连接成功<br/>";

    $res = $dbh->query(' SELECT * from goods where id = 1')->fetchAll();
    $num = $res[0]['num'];

    $dbh = null;

} catch (PDOException $e) {
    die ("Error!: " . $e->getMessage() . "<br/>");
}

for ($i=0;$i<$num;$i++){
    $redis->rPush("goodslist",1);//把库存放进redis
}





